home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dcpp / asubs.a next >
Text File  |  1993-01-17  |  2KB  |  90 lines

  1.  
  2.         ;   ASUBS.A
  3.         ;
  4.         ; (c)Copyright 1992 Obvious Implementations Corp, All Rights Reserved
  5.         ; CONFIDENTIAL, This is unpublished proprietary source code owned by Obvious Implementations Corp.
  6.         ; This material contains trade secrets of Obvious Implementations Corp.
  7.  
  8.  
  9. ;Prototype __stkargs char *HandleTriGraphs(char *);
  10. ;Prototype int hash(ubyte *, short);
  11.  
  12.         section text,code
  13.  
  14.         xdef    _HandleTriGraphs
  15.         xref    _TriGraphConvert
  16.  
  17.         ;   ptrend = HandleTriGraphs(buf)
  18.         ;
  19.         ;   Optimized assembly to replace tri-graph sequences in a
  20.         ;   buffer.
  21.  
  22. _HandleTriGraphs:
  23.         movem.l D2/A2,-(sp)
  24.         move.l    8+4(sp),A2
  25.         moveq.l #$3F,D2     ; '?'
  26. htloop        move.b    (A2)+,D0    ; get byte
  27.         beq    htdone
  28.         cmp.b    D2,D0
  29.         bne    htloop
  30.         cmp.b    (A2),D2     ; ??
  31.         bne    htloop
  32.         move.l    A3,-(sp)
  33.         subq.l    #1,A2
  34.         move.l    A2,A3
  35.         bra    htloop2     ; TRI-GRAPH!
  36. htdone
  37.         move.l    A2,D0
  38.         subq.l    #1,D0
  39.         movem.l (sp)+,D2/A2
  40.         rts
  41.  
  42.         ;   if a tri-graph sequence is found, this second loop handles
  43.         ;   it (less efficiently)
  44.  
  45. htloop2     move.b    (A2)+,D0
  46.         move.b    D0,(A3)+
  47.         beq    htdone2
  48.         cmp.b    D2,D0        ; ?
  49.         bne    htloop2
  50.         cmp.b    (A2),D2     ; ??
  51.         bne    htloop2
  52.         move.b    1(A2),D0
  53.         ext.w    D0
  54.         ext.l    D0
  55.         move.l    D0,-(sp)
  56.         jsr    _TriGraphConvert(pc)
  57.         addq.l    #4,sp
  58.         tst.l    D0
  59.         beq    htloop2
  60.         move.b    D0,-1(A3)
  61.         addq.l    #2,A2
  62.         bra    htloop2
  63.  
  64. htdone2
  65.         move.l    A3,A2
  66.         move.l    (sp)+,A3
  67.         bra    htdone
  68.  
  69.  
  70.  
  71.         xdef    _hash
  72.         xdef    @hash
  73.  
  74. _hash        move.l    4(sp),A0
  75.         move.l    8(sp),D0
  76. @hash
  77.         move.l    D2,-(sp)
  78.         moveq.l #0,D1        ; v
  79.         bra    henter
  80. hloop        rol.w    #5,D1
  81.         move.b    (A0)+,D2
  82.         eor.b    D2,D1
  83. henter        dbf    D0,hloop
  84.         move.l    D1,D0
  85.         move.l    (sp)+,D2
  86.         rts
  87.  
  88.         END
  89.  
  90.